#include <bits/stdc++.h>
using namespace std;

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};

int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    int H, W, N;
    cin >> H >> W;
    vector<string> grid(H);
    for(int i = 0; i < H; i++) cin >> grid[i];

    cin >> N;
    vector<vector<int>> medicines(H, vector<int>(W, 0));
    for(int i = 0; i < N; i++) {
        int r, c, e;
        cin >> r >> c >> e;
        r--; c--; // Adjusting to 0-based indexing
        medicines[r][c] = e;
    }

    queue<tuple<int, int, int>> q; // Queue to store (x, y, energy)
    map<pair<int, int>, int> best; // Best energy level at (x, y)

    int sx, sy, tx, ty;
    // Find S and T coordinates
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(grid[i][j] == 'S') sx = i, sy = j;
            if(grid[i][j] == 'T') tx = i, ty = j;
        }
    }

    q.push({sx, sy, 0}); // Start point with 0 energy
    best[{sx, sy}] = 0;

    while(!q.empty()) {
        auto [x, y, energy] = q.front(); q.pop();

        if(x == tx && y == ty) {
            cout << "Yes\n";
            return 0;
        }

        if(medicines[x][y] > 0) {
            energy = max(energy, medicines[x][y]);
        }

        for(int i = 0; i < 4; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if(nx >= 0 && nx < H && ny >= 0 && ny < W && grid[nx][ny] != '#' && energy > 0) {
                if(!best.count({nx, ny}) || best[{nx, ny}] < energy - 1) {
                    best[{nx, ny}] = energy - 1;
                    q.push({nx, ny, energy - 1});
                }
            }
        }
    }

    cout << "No\n";
    return 0;
}
